<template>
    <div class="u-p-20">
        <el-card shadow="never">
            <div slot="header">
                <span>
                    <b class="u-f-16">发现列表</b>
                </span>
                <router-link :to="{name:'goodsFindEdit'}" v-if="hasPerm('goodsFindEdit')">
                    <el-button type="danger" size="small" icon="el-icon-plus" class="u-right u-5mt" round>添加发现</el-button>
                </router-link>
            </div>

            <el-form :inline="true" :model="queryForm" size="small" class="u-text-center">
                <el-form-item label="显示状态">
                    <el-select v-model="queryForm.status" clearable>
                        <el-option label="全部" value=""></el-option>
                        <el-option label="显示" value="1"></el-option>
                        <el-option label="不显示" value="2"></el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="商品名称">
                    <el-input v-model="queryForm.keyword" placeholder="输入商品标题查询" clearable></el-input>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" @click="getPageData(true)">查询</el-button>
                </el-form-item>
            </el-form>

            <el-table :data="tableData" class="u-mt-10" v-viewer>
                <el-table-column label="id" prop="id" width="100"></el-table-column>
                <el-table-column label="商品信息">
                    <template slot-scope="scope">
                        <el-image style="max-width: 90px;max-height:90px"
                                  :src="scope.row.goods_img"
                                  :data-src="scope.row.goods_img"
                                  fit="cover"
                                  lazy>
                        </el-image>
                        <br />
                        <el-tag v-html="scope.row.goods_title"></el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="显示状态" >
                    <template slot-scope="scope" v-if="hasPerm('goodsStatus')">
                        <el-switch v-model="scope.row.status"
                                   :active-value="1"
                                   :inactive-value="2"
                                   active-color="#13ce66"
                                   @change="handleStatus(scope.row.id,scope.row.status)">
                        </el-switch>
                    </template>
                </el-table-column>

                <el-table-column label="标签">
                    <template slot-scope="scope">
                        <el-tag v-html="scope.row.label"></el-tag>
                    </template>
                </el-table-column>

                <el-table-column label="添加日期" prop="create_time"></el-table-column>

                <el-table-column label="操作" width="120">
                    <template slot-scope="scope">
                        <el-dropdown>
                            <span class="el-dropdown-link">
                                操作<i class="el-icon-arrow-down el-icon--right"></i>
                            </span>

                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item 
                                @click.native="handleRoute(scope.row.id,'goodsFindEdit')" v-if="hasPerm('goodsFindEdit')">
                                    <el-button size="mini" type="text" >编辑</el-button>
                                </el-dropdown-item>

                                <el-dropdown-item @click.native="handleDelete(scope.row.id)" v-if="hasPerm('goodsFindDelBtn')">
                                    <el-button size="mini" type="text" >删除</el-button>
                                </el-dropdown-item>
                            </el-dropdown-menu>

                        </el-dropdown>

                    </template>

                </el-table-column>
            </el-table>

            <div class="u-mt-20 u-text-center">
                <el-pagination
                    background
                    @size-change="handleSizeChange"
                    @current-change="handlePageChange"
                    :current-page="currentPage"
                    :page-sizes="[10, 20, 30, 40, 50]"
                    :page-size="limit"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
                </el-pagination>
            </div>
        </el-card>
    </div>
</template>

<script>
    import commonPage from '@/mixins/common-page'

    export default {
        mixins:[commonPage],
        data() {
            return {
                apiName:'goodsFind',
                queryForm:{
                    status:'',
                    keyword:''
                }
            }
        },
        methods:{

        }
    }
</script>
